package com.bobi.tfca.ui.adapter

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter

typealias HomeHandleFragment = () -> Fragment
open class HomePagerAdapter(fragment: Fragment): FragmentStateAdapter(fragment){

    private val fragments = mutableListOf<HomeHandleFragment>()

    override fun getItemCount(): Int = fragments.size

    override fun createFragment(position: Int): Fragment = fragments[position].invoke()

    fun add(fragment: HomeHandleFragment): HomePagerAdapter{
        fragments.add(fragment)
        return this
    }

    fun add(fragmentList: List<HomeHandleFragment>): HomePagerAdapter{
        fragments.addAll(fragmentList)
        return this
    }
}